//
//  MessageCell.m
//  Molian
//
//  Created by wansong on 4/14/15.
//  Copyright (c) 2015 xiaocan. All rights reserved.
//

#import "MessageCell.h"

@implementation MessageCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        CGFloat cellHeight = 60;
        
        self.accessoryType = UITableViewCellAccessoryNone;
            
        // 用户头像
        self.avatarImgView = [[UIImageView alloc]init];
        self.avatarImgView.frame = CGRectMake(10, (cellHeight-40)/2, 40, 40);
        self.avatarImgView.layer.masksToBounds = YES;//开启圆角
        [self.avatarImgView.layer setCornerRadius:5.0f];
        [self.avatarImgView setContentMode:UIViewContentModeScaleAspectFill];
        [self.contentView addSubview:self.avatarImgView];
        
        // 消息标记
        self.badgeBtn = [[UIButton alloc]initWithFrame:CGRectMake(36, 4, 18, 18)];
        self.badgeBtn.layer.masksToBounds = YES;
        [self.badgeBtn.layer setCornerRadius:9.0f];
        [self.badgeBtn setBackgroundColor:UIColorFromRGB(0xfd534b)];
        [self.badgeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
        // 用户名字
        self.nameLabel = [[UILabel alloc]init];
        self.nameLabel.frame = CGRectMake(60, 15, 90, 15);
        self.nameLabel.font = [UIFont fontWithName:FontName size:15];
        self.nameLabel.textColor = [UIColor blackColor];
        self.nameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:self.nameLabel];
        
        // 消息
        self.msgLabel = [[UILabel alloc]init];
        self.msgLabel.frame = CGRectMake(80, 50, 22, 12);
        self.msgLabel.font = [UIFont fontWithName:FontName size:11];
        [self.msgLabel.layer setCornerRadius:6];
        self.msgLabel.clipsToBounds = YES;
        self.msgLabel.textAlignment = NSTextAlignmentCenter;
        self.msgLabel.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.msgLabel];
        
        // 时间
        self.timeLabel = [[UILabel alloc]init];
        self.timeLabel.frame = CGRectMake(110, 50, 90, 12);
        self.timeLabel.font = [UIFont fontWithName:FontName size:11];
        self.timeLabel.textAlignment = NSTextAlignmentLeft;
        self.timeLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.timeLabel];
        
    }
    return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
